﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TicketMovie.Admin
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        private DataClasses1DataContext dc = new DataClasses1DataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.RepeaterCountryList.DataSource = this.dc.Countries.ToList();
                this.RepeaterCountryList.DataBind();
            }
        }
        protected void LinkButtonXoa_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton lb = (LinkButton)sender;
                HiddenField hd = (HiddenField)lb.Parent.FindControl("HiddenFieldDelCatalogue");
                Country country = this.dc.Countries.Single(cou => cou.code_country == Convert.ToInt32(hd.Value));
                this.dc.Countries.DeleteOnSubmit(country);
                this.dc.SubmitChanges();
                this.message_error.Visible = false;
                this.message_thanhcong.Visible = true;
            }
            catch
            {
                this.message_error.Visible = true;
                this.message_thanhcong.Visible = false;
            }
            this.RepeaterCountryList.DataSource = this.dc.Countries.ToList();
            this.RepeaterCountryList.DataBind();
        }
    }
}